<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>忘记密码</title>
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <script src="../../layui/layui.js"></script>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <style>
        html,
        body {
            height: 100%;
            width: 100%;
            background-image: url(../../images/denglubeijing.jpg);
            background-size: 100%;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: center;
        }

        .denglu {
            background-color: #ffffff;
            width: 390px;
            height: 280px;
            border-radius: 6px;
        }

        .yonghudenglu {
            text-align: center;
            font-size: 20px;
            margin: 30px 0;
            color: #666;
            font-weight: 500;
        }

        .zhanghao {
            width: 84%;
            margin: 30px 0;
            margin-left: 8%;
        }

        .forgetmima {
            margin: -24px 32px;
            color: #666;
            font-weight: normal;
            float: right;
        }

        .dengluanniu {
            background-color: #dd4b39;
            width: 84%;
            margin: 0px 8%;
        }

        .layui-input {
            height: 45px;
            padding-left: 40px;
            margin-top: 20px;
            margin-bottom: 50px;
        }

        .icon {
            position: absolute;
            margin: 11px;
            font-size: 20px;
            color: #909399;
        }

        .layui-btn {
            font-size: 16px;

            height: 45px;
        }
    </style>
</head>

<body>
    <div class="denglu">
        <div class="yonghudenglu">忘记密码</div>
        <div class="zhanghao">
            <i class="layui-icon layui-icon-username icon"></i>
            <input type="text" name="zhanghao" required lay-verify="required" id="zhanghao" placeholder="请输入账号"
                autocomplete="off" class="layui-input zhanghaozhanghao">
        </div>
        <div class="dengluanniu">
            <button type="button" class="layui-btn layui-btn-danger dengluanniu" id="btn">确定</button>
        </div>
    </div>
</body>


<script>
    $('.denglu').keydown(function (e) {
        if (e.keyCode === 13) {
            $(".dengluanniu").trigger("click");
            return false
        }
    });
    //点击确定后的弹窗
    var url = "http://47.105.118.98:9013";
    layui.use(['layer'], function () {
        var btn = document.getElementById("btn");
        btn.onclick = function () {
            // layer.confirm('您的密码是:123456')
            // console.log(document.getElementById("zhanghao").value)
            var zhanghao = document.getElementById("zhanghao").value
            $.ajax({
                url: url + "/user/updateUserPassword",
                method: "post",
                data: {
                    userName: zhanghao
                },
                success: function (data) {
                    console.log(data)
                    if (data.code === 200) {
                        layer.msg(data.msg)
                        setInterval(function () {
                            window.location = 'denglu.html'
                        }, 3000)

                    } else {
                        layer.msg(data.msg)
                    }

                },
                error: function (err) {
                    layer.msg('找回密码失败！')
                }
            })
        };

    })




</script>

</html>